package FlowGram.Application.CommandHost.FinchActionListeners;

import java.awt.event.ActionEvent;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import FlowGram.Application.Parser.Actions.Control.FunctionDefinition;
import FlowGram.Application.Parser.Actions.Control.Repeat;

public class FunctionDefListener extends FinchActionListener{
	
	JFrame frame;
	
	FunctionDefinition fDef;
	
	public FunctionDefListener(JFrame frame){
		this.frame = frame;
		fDef = new FunctionDefinition();
	}
	
	
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
			
		String fName = (String)JOptionPane.showInputDialog(
				frame,
				"Create new function called:",
				"Function Definition",
				JOptionPane.QUESTION_MESSAGE);
		
		if(fName != null){
			fDef.setName(fName);
			FunctionDefinition.registerFunction(fDef);		
			addCode(fDef);
		}
	}
	
}
